<?php
global $_W, $_GPC;
$op = !empty($_GPC['op']) ? $_GPC['op'] : 'display';
if ($op == 'delete') {
	$id = intval($_GPC['id']);
	pdo_delete($this->tablevolist, array('id' => $id));
	message('删除成功！', referer(), 'success');
} else if ($op == 'post') {
	if (checksubmit('submit')) {
		if (empty($_GPC['username'])) {
			message('抱歉，请输入微信昵称！');
		}
		$data = array('username' => $_GPC['username'], 'avatar' => $_GPC['avatar']);
		if (!empty($id)) {
			message('抱歉，提交信息有误！');
		} else {
			pdo_insert('bsht_tbk_volist', $data);
			$id = pdo_insertid();
		}
		message('添加成功！', $this->createWebUrl('vorderlist', array('op' => 'display')), 'success');
	}
} else if ($op == 'display') {
	$pindex = max(1, intval($_GPC['page']));
	$psize = 50;
	$total = pdo_fetchcolumn("SELECT count(*) FROM " . tablename('bsht_tbk_volist'));
	$sql = "SELECT * FROM " . tablename('bsht_tbk_volist') . " LIMIT " . ($pindex - 1) * $psize . ',' . $psize;;
	$list = pdo_fetchall($sql);
	$pager = pagination($total, $pindex, $psize);
}
include $this->template('listvolist');